package com.hunttown.mes.common.keys;

import com.hunttown.mes.common.utils.PropertyUtils;

/**
 * created by wangjunfu on 2017-10-24
 */
public class KeyConstants {

    //缓存前缀（建议使用项目名称，保证每个项目唯一）
    private String PREFIX = PropertyUtils.getValue("cache.prefix");

    //region static方法中调用非static属性方法
    private static KeyConstants kc = new KeyConstants();

    private KeyConstants init() {
        return this;
    }

    static String getPrefix() {
        kc.init();
        return kc.PREFIX;
    }
    //endregion

    // 网站未登录时显示的公司信息

    public static final String DEFAULT_COMPANY_INFO = "阿帕图MES管理平台";
    public static final String DEFAULT_COMPANY_COPYRIGHT = "Copyright © 2024 阿帕图 Apertus.Cn 鲁ICP备2024101865号";

    //region 通用缓存KEY设置

    //通用缓存配置
    public static final String COMMON_CACHE_INFO_OBJECT_KEY = getPrefix() + "_commoncache_object_";
    //endregion

    //region 管理员 [Shiro] 权限

    /**
     * redis shiro 权限KEY
     */
    public static final String REDIS_SHIRO_SESSION_ADMIN = getPrefix() + "-analysis-shiro-session_";

    /**
     * session status KEY
     */
    public static final String SESSION_STATUS_ADMIN = getPrefix() + "-shiro-online-status";

    /**
     * 登录用户信息 缓存到SESSION中
     */
    public static final String LOGIN_SESSION_ADMIN = getPrefix().toUpperCase() + "_LOGIN_SESSION_";
    //endregion

    //region 管理员

    // 功能菜单
    public static final String MENU_ALL_CACHE_KEY = getPrefix() + "_admin_menu_cache_all";
    public static final String MENU_INFO_CACHE_KEY_CODE = getPrefix() + "_admin_menu_info_code_";

    // 管理员-角色-菜单（供VM页面是否显示按钮使用）
    public static final String MENU_ROLE_ADMIN_CACHE_HSET = getPrefix() + "_admin_role_menu_code";

    // 权限角色
    public static final String ROLE_ALL_CACHE_KEY = getPrefix() + "_admin_role_cache_all";

    // 管理用户COOKIE
    public static final String ADMIN_COOKIE = getPrefix() + "_pin";
    public static final String ADMIN_COOKIE_NICK = getPrefix() + "_pin_nick";
    public static final String ADMIN_COOKIE_STATUS = getPrefix() + "_pin_status";
    public static final String ADMIN_COOKIE_FLAG = getPrefix() + "_pin_flag";
    public static final String ADMIN_COOKIE_ONLYKEY = getPrefix() + "_pin_key";

    // 管理用户登录缓存
    public static final String ADMIN_SESSION_CACHE_KEY = getPrefix() + "_pin_";

    // 管理用户信息
    public static final String ADMIN_INFO_CACHE_KEY_PIN = getPrefix() + "_admin_info_pin_"; //（+entid）
    public static final String ADMIN_INFO_CACHE_KEY_ID = getPrefix() + "_admin_info_id_";
    public static final String ADMIN_INFO_CACHE_KEY_NICKNAME = getPrefix() + "_admin_info_nick_"; //（+entid）
    public static final String ADMIN_INFO_CACHE_KEY_MOBILE = getPrefix() + "_admin_info_mobile_"; //（+entid）

    // 管理用户登录失败次数
    public static final String ADMIN_LOGIN_ERROR_KEY = getPrefix() + "_admin_loginerror_count_";

    //endregion

    //region 网站设置
    public static final String WEBSITE_INFO_CACHE_KEY_ENTID = getPrefix() + "_website_info_entid_";
    public static final String WEBSITE_INFO_CACHE_KEY_DOMAIN = getPrefix() + "_website_info_domain_";
    //endregion

    //region 企业ID

    // 存储当前用户的企业ID（如果为空则去重新登录）
    // 仅供：后端管理员和前端会员使用，因为它们都能获取request，若不使用同一个KEY，则Service层识别不到
    // 关键词为：用户PIN（管理员取的是姓名的拼音，会员取的是手机号，不冲突）
    public static final String WEBSITE_CURRENT_ENTERPRISE_ID = getPrefix() + "_website_current_enterprise_id_";

    //endregion

    //region 全站分类

    /**
     * 全站分类
     */
    public static final String NEWSCATALOG_INFO_KEY_ID = getPrefix() + "_catalog_id_";
    public static final String NEWSCATALOG_INFO_KEY_ENNAME = getPrefix() + "_catalog_enname_"; //（+entid）

    //前端网站首页分类
    public static final String INDEXCATE_LIST_KEY = getPrefix() + "_index_catelist_"; //（+entid）
    //endregion

    //region 网站参数
    public static final String CONFIGPARAM_INFO_KEY = getPrefix() + "_configparam_key_"; //（+entid）
    //endregion

    //region API接口

    /**
     * API接口名称缓存
     */
    public static final String API_INFO_TOKEN_KEY = getPrefix() + "_api_info_token_";

    /**
     * API接口使用频率
     */
    public static final String API_INFO_TOKEN_TIMES = getPrefix() + "_api_token_count_";
    //endregion

    //region 短信管理

    //短信模板ID，转移到枚举中：SmsTempleteEnum
    //public static final String SMS_TEMPLETE_SIGN = "王君富生活笔记";          //短信签名（个人）
    //public static final Integer SMS_TEMPLETE_ID_BOOKING = 449461;           //客户预订：449461（鑫）
    //public static final Integer SMS_TEMPLETE_ID_BOOKING_CHANGE = 449553;    //客户预订变更：449553（鑫）
    //public static final Integer SMS_TEMPLETE_ID_BOOKING_MORE = 463857;      //客户预订（一活多车）：463857（鑫）
    //public static final Integer SMS_TEMPLETE_ID_BINDMOBILE = 422260;        //绑定手机：422260（鑫）766510（个人）
    //public static final Integer SMS_TEMPLETE_ID_USERLOGIN = 448522;         //用户登录：448522（鑫）766513（个人）
    //public static final Integer SMS_TEMPLETE_ID_ARREARS_NOTICE = 766515;    //帐户余额：766515（个人）
    //public static final Integer SMS_TEMPLETE_ID_POWEROFF_MORE = 766517;     //分闸通知：766517（个人）

    /**
     * 短信发送频率
     */
    public static final String SMS_SEND_TIMES = getPrefix() + "_sms_send_times_";
    //endregion

    //region 公司管理

    /**
     * 公司信息
     */
    public static final String COMPANY_INFO_KEY_ID = getPrefix() + "_company_id_";
    //endregion

    //region 会员管理

    // 会员 登录COOKIE
    public static final String USER_COOKIE = getPrefix() + "_upin";
    public static final String USER_COOKIE_NICK = getPrefix() + "_upin_nick";
    public static final String USER_COOKIE_STATUS = getPrefix() + "_upin_status";
    public static final String USER_COOKIE_FLAG = getPrefix() + "_upin_flag";
    public static final String USER_COOKIE_ONLYKEY = getPrefix() + "_upin_key";

    // 会员 登录缓存
    public static final String USER_SESSION_CACHE_KEY = getPrefix() + "_upin_";

    /**
     * 会员信息
     */
    public static final String USER_INFO_KEY_ID = getPrefix() + "_user_id_";
    public static final String USER_INFO_KEY_TRUENAME = getPrefix() + "_user_truename_"; //（+entid）
    public static final String USER_INFO_KEY_PIN = getPrefix() + "_user_pin_"; //（+entid）
    public static final String USER_INFO_KEY_MOBILE = getPrefix() + "_user_mobile_"; //（+entid）

    // 区域信息
    public static final String IOT_REGION_INFO_KEY_ID = getPrefix() + "_iot_region_id_";
    //endregion

    //region 会员Shiro权限

    /**
     * redis shiro 权限KEY
     */
    public static final String REDIS_SHIRO_SESSION_USER = getPrefix() + "-user-shiro-session_";

    /**
     * session status KEY
     */
    public static final String SESSION_STATUS_USER = getPrefix() + "-user-shiro-online-status";

    /**
     * 登录用户信息 缓存到SESSION中
     */
    public static final String LOGIN_SESSION_USER = "LOGIN_SESSION_USER_";
    //endregion

    //region 车辆管理

    /**
     * 车辆信息
     */
    public static final String CARS_INFO_KEY_ID = getPrefix() + "_car_id_";
    public static final String CARS_INFO_KEY_CARNUMBER = getPrefix() + "_car_number_"; //（+entid）
    //endregion

    //region 司机管理

    /**
     * 司机信息
     */
    public static final String DRIVER_INFO_KEY_ID = getPrefix() + "_driver_id_";
    public static final String DRIVER_INFO_KEY_NAME = getPrefix() + "_driver_name_"; //（+entid）
    //endregion

    //region 员工管理
    public static final String STAFF_INFO_CACHE_KEY_ID = getPrefix() + "_staff_info_id_";
    //endregion

    //region 部门管理
    public static final String DEPARTMENT_INFO_CACHE_KEY_ID = getPrefix() + "_dep_info_id_";
    //endregion

    //region 文件上传

    //是否上传过文件
    public static final String UPLOAD_SIGN_COOKIE = getPrefix() + "_isupload";
    //endregion

    //region 文章管理

    //文章
    public static final String NEWS_INFO_KEY_ID = getPrefix() + "_news_id_";
    //endregion

    //region 物料采销
    public static final String PURCHASE_INFO_KEY_ID = getPrefix() + "_purchase_id_";
    //endregion

    //region WEB菜单
    public static final String WEB_MENU_KEY_LIST = getPrefix() + "_web_menu_";
    public static final Integer WEB_MENU_CACHE_TIME = 60; //缓存时间，单位：秒
    //endregion

    //region 定时任务
    public static final String TIMEDTASK_LIST_KEY = getPrefix() + "_timedtask_list";
    //endregion

    //region 全国行政区5级
    public static final String ANALYSISREGION_INFO_KEY_ID = getPrefix() + "_analysis_region_id_";
    //endregion

    //region 静态常量设置

    //region 流程环节配置

    //司机报销
    //public static final Integer BUSINESS_ID_DRIVER_BX = 3;            //司机报销流程ID
    public static final Integer LINENODE_DRIVER_BX_FEIYONGFAFANG = 2;   //财务主管发放费用环节
    public static final Integer LINENODE_DRIVER_BX_EXECFEIYONG = 3;     //执行人发放费用环节

    //订单结账
    //public static final Integer BUSINESS_ID_ORDER_CHECKOUT = 4;            //订单结账流程ID（改为实时获取）
    public static final Integer LINENODE_ORDER_CHECKOUT_KAIFAPIAO = 2;       //财务开票
    public static final Integer LINENODE_ORDER_CHECKOUT_SONGFAPIAO = 3;      //送发票
    public static final Integer LINENODE_ORDER_CHECKOUT_QUZHIPIAO = 4;       //取支票
    public static final Integer LINENODE_ORDER_CHECKOUT_DDSHOUZHIPIAO = 5;   //调度收支票
    public static final Integer LINENODE_ORDER_CHECKOUT_DDJIEZHANG = 6;      //调度结账
    public static final Integer LINENODE_ORDER_CHECKOUT_CWSHOUZHIPIAO = 7;   //财务收支票
    public static final Integer LINENODE_ORDER_CHECKOUT_SONGZHIPIAO = 8;     //银行送支票
    public static final Integer LINENODE_ORDER_CHECKOUT_SHOUJINZHANGDAN = 9; //财务收进账单
    public static final Integer LINENODE_ORDER_CHECKOUT_CWSHENGHE = 10;      //财务审核

    //endregion

    //region 工资考勤天数
    public static final Float SALARY_ATTENDANCE_DAYS = 21.75F;
    //endregion

    //endregion

    //region LBS定位
    //高德轨迹KEY
    public static final String LBS_GAODE_TRACKKEY = "038beb4616c211d48f16d513ca19fb56";

    //轨迹ID
    public static final String LBS_TRACKID_TACKCODE = getPrefix() + "_lbs_trackcode_";

    //轨迹信息KEY
    public static final String LBS_TRACKINFO_TACKCODE = getPrefix() + "_lbs_trackinfo_trackcode_";

    //轨迹保存频率
    public static final String LBS_TRACKPOINT_SAVE_FREQUENCY = getPrefix() + "_lbs_trackpoint_frequency_";

    //region 坐标采集频率限制
    //坐标：x,y
    public static final String LBS_TRACKPOINT_NOSAVE_10METER = getPrefix() + "_lbs_trackpoint_nosave_10m_";

    //时间：有效期10分钟
    public static final String LBS_TRACKPOINT_NOSAVE_10MIN = getPrefix() + "_lbs_trackpoint_nosave_10f_";

    //锁
    public static final String LBS_TRACKPOINT_NOSAVE_LOCK = getPrefix() + "_lbs_trackpoint_nosave_lock_";
    //endregion

    //终端编码
    public static final String LBS_TERMINAL_TEMINALCODE = getPrefix() + "_lbs_terminal_terminalcode_"; //ent_id

    //终端注册
    public static final String LBS_TERMINAL_REGISTER_AUTHCOD = getPrefix() + "_lbs_terminal_register_authcode_"; //ent_id

    //endregion

    //region 第三方接口
    //企业Token
    public static final String THIRDPARTY_TOKEN_ID = getPrefix() + "_thirdparty_token_";
    //endregion
}